<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%-- <%@ taglib prefix="c" uri="core" %> --%>
<!DOCTYPE html>
<html>
<head>
<title>JSP标签库</title>
<style type="text/css">
span {
  color: red;
}
</style>
</head>
<body>
  将\${param.f1}的值赋予作用域为request的变量field1
  <br>
  <c:set var="field1" value="${param.f1}" scope="request" />
  <%-- 当<c:set>标签内没有指定scope属性的值时，默认scope属性的值为page --%>
  <c:set var="field2" value="${param.f2}" />
  将\${param.f2}的值赋予作用域为request的变量field2
  <br>
  field1的值为<c:out value="<span>" escapeXml="false" />${field1}<c:out value="</span><br>" escapeXml="false" />
  field2的值为<span><%=pageContext.getAttribute("field2")%></span>
  <br>
  <%-- 当<c:if>标签的test属性值的结果为真时，执行内部语句 --%>
  <c:if test="${param.f1==param.f2}">
    <c:out value="\${param.f1==param.f2}" />
    <br>
  </c:if>
  <c:choose>
    <c:when test="${field1>0}">
      <%-- 当escapeXml属性的值为false时，禁用纯文本转换 --%>
      <c:out value="field1的值大于0<br>" escapeXml="false" />
    </c:when>
    <c:when test="${field1<0}">
      <%="field1的值小于0"%><br>
    </c:when>
    <c:otherwise>
      <c:out value="field1的值等于0<br>" escapeXml="false" />
      <br>
    </c:otherwise>
  </c:choose>
  <%="<c:forEach var='a' begin='2' end='10' step='2'>"%>
  令field1的值每次增加2，重复5次
  <br>
  <c:forEach var="a" begin="2" end="10" step="2">
    <c:out value="${field1=field1+a}<br>" escapeXml="false" />
  </c:forEach>
  <%="</c:forEach>"%>
  移除变量field1和field2
  <br>
  <c:remove var="field1" />
  <c:remove var="field2" scope="page" />
  field1的值为<c:out value="${field1}" default="null" />
  <br>
  field2的值为<c:out value="${pageScope.field2}" default="null" />
  <%
      session.removeAttribute("bean");
      // 使会话无效后，将取消所有会话绑定的对象
      session.invalidate();
  %>
</body>
</html>
